import { createRouter, createWebHistory } from 'vue-router'


// 二级路由  把数组抛出去，在layout页面引用渲染左侧菜单
export const menu_router = [
  {
    path: '/',
    name: 'home',
    meta: {
      title: '首页'
    },
    component: () => import('../views/home/indexView.vue')
  },
  {
    path: '/manage',
    name: 'manage',
    meta: {
      title: '物业管理'
    },
    // 三级路由
    children: [
      {
        path: '/manage/list',
        meta: {
          title: '列表'
        },
        component: () => import('../views/list/indexView.vue')
      },
      {
        path: '/manage/room',
        meta: {
          title: '房屋'
        },
        component: () => import('../views/room/indexView.vue')
      }
    ]
  },
  {
    path: '/propertymanage',
    name: 'propertymanage',
    meta: {
      title: '房源管理'
    },
    children: [
      {
        path: '/propertymanage/houselist',
        meta: {
          title: '房源列表'
        },
        component: () => import('../views/manageRoom/indexView.vue')
      },
      {
        path: '/propertymanage/roomadd',
        meta: {
          title: '新增房源'
        },
        component: () => import('../views/manageRoomAdd/indexView.vue')
      },
      {
        path: '/propertymanage/roomedit',
        meta: {
          title: '编辑房源'
        },
        component: () => import('../views/manageRoomEdit/indexView.vue')
      }
    ]
  },
  {
    path: '/vlist',
    name: 'vlist',
    meta: {
      title: '虚拟列表'
    },
    component: () => import('../views/vlist/indexView.vue')
  },
  {
    path: '/parent',
    name: 'parent',
    meta: {
      title: '组件通信'
    },
    component: () => import('../views/parent/indexView.vue')
  },
  {
    path: '/map',
    name: 'map',
    meta: {
      title: '高德地图'
    },
    component: () => import('../views/map/indexView.vue')
  },
]

const router = createRouter({
  // 一级路由
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'layout',
      component: () => import('../views/layout/indexView.vue'),
      children: menu_router
    },
    {
      path: '/login',
      name: 'login',
      component: () => import('../views/login/indexView.vue')
    },
    {
      path: '/register',
      name: 'register',
      component: () => import('../views/register/indexView.vue')
    },
    {
      path: '/oauth/xielin',
      name: 'oauth',
      component: () => import('../views/oauth/indexView.vue')
    },
    {
      path: '/404',
      name: '404',
      component: () => import('../views/404/indexView.vue')
    },
    {
      path: '/:pathMatch(.*)*',
      redirect: '/404'
    }
  ]
})



export default router
